﻿Imports System.Windows.Forms

Public Class CheckDetails

    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
        Me.Close()
    End Sub

    Friend Function CheckDetails(ByVal ProgramDetails As ProgramDetails) As ProgramDetails
        For Each item As String In My.Settings.CorrectedNames
            If item = ProgramDetails.Name Then
                ProgramDetails.Name = item
                ProgramDetails.Directory = My.Settings.CorrectedDirectories(My.Settings.CorrectedNames.IndexOf(item))
                ProgramDetails.Extension = My.Settings.CorrectedExtensions(My.Settings.CorrectedNames.IndexOf(item))
                Return ProgramDetails
                Exit Function
            End If
        Next
        FileName.Text = ProgramDetails.Name
        FileDir.Text = ProgramDetails.Directory
        FileExt.Text = ProgramDetails.Extension
        ShowDialog()
        ProgramDetails.Directory = FileDir.Text
        ProgramDetails.Extension = FileExt.Text
        My.Settings.CorrectedNames.Add(ProgramDetails.Name)
        My.Settings.CorrectedDirectories.Add(ProgramDetails.Directory)
        My.Settings.CorrectedExtensions.Add(ProgramDetails.Extension)
        Return ProgramDetails
    End Function
End Class

Friend Class ProgramDetails
    Dim _name As String
    Public Property Name() As String
        Get
            Return _name
        End Get
        Set(ByVal value As String)
            _name = value
        End Set
    End Property

    Dim _dir As String
    Public Property Directory() As String
        Get
            Return _dir
        End Get
        Set(ByVal value As String)
            _dir = value
        End Set
    End Property

    Dim _ext As String
    Public Property Extension() As String
        Get
            Return _ext
        End Get
        Set(ByVal value As String)
            _ext = value
        End Set
    End Property
End Class